public ContextManagerResident( string deploymentId, ContextDefinition contextDefinition) { ContextDefinition = contextDefinition; ContextRuntimeDescriptor = new ContextRuntimeDescriptor(contextDefinition.ContextName, deploymentId, this); }
private static IDictionary<string, object> BuildContextPropertiesMap( int agentInstanceId, object[] allPartitionKeys, ContextDefinition contextDefinition) { IDictionary<string, object> props = new Dictionary<string, object>(); props.Put(ContextPropertyEventType.PROP_CTX_NAME, contextDefinition.ContextName); props.Put(ContextPropertyEventType.PROP_CTX_ID, agentInstanceId); var controllerFactories = contextDefinition.ControllerFactories; if (controllerFactories.Length == 1) { controllerFactories[0].PopulateContextProperties(props, allPartitionKeys[0]); return props; } for (var level = 0; level < controllerFactories.Length; level++) { var nestedContextName = controllerFactories[level].FactoryEnv.ContextName; IDictionary<string, object> nestedProps = new Dictionary<string, object>(); nestedProps.Put(ContextPropertyEventType.PROP_CTX_NAME, nestedContextName); if (level == controllerFactories.Length - 1) { nestedProps.Put(ContextPropertyEventType.PROP_CTX_ID, agentInstanceId); } controllerFactories[level].PopulateContextProperties(nestedProps, allPartitionKeys[level]); props.Put(nestedContextName, nestedProps); } return props; }
public static MappedEventBean BuildContextProperties( int agentInstanceId, object[] allPartitionKeys, ContextDefinition contextDefinition, StatementContext statementContextCreate) { var props = BuildContextPropertiesMap(agentInstanceId, allPartitionKeys, contextDefinition); return statementContextCreate.EventBeanTypedEventFactory.AdapterForTypedMap( props, contextDefinition.EventTypeContextProperties); }
public void FromEnumTestNominal() { ContextDefinitionBuilder toTest = new ContextDefinitionBuilder(); toTest.AnyOf("test", "test", typeof(testEnum), true); ContextDefinition ctx = toTest.definition; Assert.Equal(3, ctx.Items.Count); Assert.Contains("1", (from i in ctx.Items select i.Key)); Assert.Contains("one", (from i in ctx.Items select i.Literal)); }
internal void ExtractContextRules() { //all evaluators used in this workflow List <string> evalIds = (from e in this.WorkflowManager.WorkFlow.Evaluators select e.Id).ToList(); //all of the rules that use the evaluators List <Rule> evalRules = (from l in this.WorkflowManager.WorkFlow.Equations where evalIds.Contains(l.First.Id) select l.First) .Union(from r in this.WorkflowManager.WorkFlow.Equations where null != r.Second && evalIds.Contains(r.Second.Id) select r.Second).ToList(); //all rules that pass context List <string> rulesThatHaveContext = (from r in evalRules where r.Context != null select r.Id).Distinct().ToList(); //all contexts used List <string> contextUsed = (from r in evalRules where r.Context != null select r.Context.Name.ToLower()).Distinct().ToList(); //this is the inferred list this.ContextUsed = new List <ContextDefinition>(from c in this.WorkflowManager.WorkFlow.ContextDefinitions where contextUsed.Contains(c.Name.ToLower()) select(ContextDefinition) c.Clone()); //clear all items, we will infer from rules //this is the basis for our test cases this.ContextUsed.ForEach(e => e.Items = new List <ContextItem>()); //go through all of the rules, and define the contexts only for the keys used rulesThatHaveContext.ForEach(x => { List <Rule> matchOnId = (from r in evalRules where r.Id.Equals(x, StringComparison.OrdinalIgnoreCase) select r).ToList(); matchOnId.ForEach(e => { Context rulesContext = e.Context; ContextDefinition def = ContextUsed.FirstOrDefault(c => c.Name.Equals(rulesContext.Name)); ContextDefinition full = this.WorkflowManager.GetContextDefinition(rulesContext.Name); List <ContextItem> inferred = new List <ContextItem>(from z in rulesContext.Keys select new ContextItem() { Key = z, Literal = z }); inferred.ForEach(i => { ContextItem defined = full.Items.FirstOrDefault(g => g.Key.Equals(i.Key, StringComparison.OrdinalIgnoreCase)); i.Literal = defined.Literal ?? i.Literal; if (def.Items.Count(g => g.Key.Equals(i.Key, StringComparison.OrdinalIgnoreCase)) == 0) { def.Items.Add(i); } }); }); }); }
public void AddContext( ContextDefinition contextDefinition, EPStatementInitServices services) { var deployment = deployments.Get(services.DeploymentId); if (deployment == null) { deployment = new ContextDeployment(); deployments.Put(services.DeploymentId, deployment); } deployment.Add(contextDefinition, services); }
public void ActivateContext( string name, ContextDefinition definition) { // we are checking that all is resolved var detail = ModuleIncidentals.Contexts.Get(name); if (detail == null) { throw new ArgumentException("Failed to find context information for '" + name + "'"); } ServicesContext.ContextManagementService.AddContext(definition, this); }
public void Add( ContextDefinition contextDefinition, EPStatementInitServices services) { var contextName = contextDefinition.ContextName; var mgr = contexts.Get(contextName); if (mgr != null) { throw new EPException("Context by name '" + contextDefinition.ContextName + "' already exists"); } var contextManager = new ContextManagerResident(services.DeploymentId, contextDefinition); contexts.Put(contextName, contextManager); }
public IBuildIntention <IImplementationDefinition> GetBuildIntention(IConversionContext context) { var(toBuild, maker) = ImplementationDefinition.Create(); return(new BuildIntention <IImplementationDefinition>(toBuild, () => { maker.Build( TransformerExtensions.Convert <IVerifiableType>(OutputType.GetOrThrow(), context), ContextDefinition.IfIs(x => x.GetValue()).GetOrThrow().Convert(context), ParameterDefinition.IfIs(x => x.GetValue()).GetOrThrow().Convert(context), Scope.Convert(context), MethodBody.Select(x => x.GetOrThrow().ConvertElementOrThrow(context)).ToArray(), StaticInitialzers.Select(x => x.ConvertElementOrThrow(context)).ToArray()); })); }
private ArticulateEvaluator ArticulateEvaluator(LogicDefine.Rule x) { ArticulateEvaluator toBuild = new ArticulateEvaluator() { Id = x.Id }; LogicDefine.Evaluator ev = this.workflow.Evaluators.FirstOrDefault(g => g.Id == x.Id); toBuild.Literal = ev.Description; toBuild.TrueCondition = x.TrueCondition; if (x.Context != null) { ContextDefinition ctxDef = this.workflow.ContextDefinitions.FirstOrDefault(g => g.Name.Equals(x.Context.Name, StringComparison.OrdinalIgnoreCase)); string ctxLit = string.Join(",", (from i in ctxDef.Items where x.Context.Keys.Contains(i.Key) select i.Literal)); ArticulateContext articulateContext = new ArticulateContext() { Literal = ctxDef.Literal, Value = ctxLit }; //var intent = this.logicIntents.FirstOrDefault(g => g.evaluatorId == x.Id); //if (intent != null && intent.Context != null) //{ // articulateContext.Literal = intent.Context.Literal; // if (intent.Context.Values != null) // { // ContextItem match = intent.Context.Values.FirstOrDefault(k => k.Key == ctx.Key); // if (!string.IsNullOrEmpty(match.Key)) // { // ctx.Literal = match.Literal; // } // } //} //if (string.IsNullOrEmpty(ctx.Literal)) { ctx.Literal = "Inferred"; } //if (string.IsNullOrEmpty(articulateContext.Literal)) { articulateContext.Literal = "Inferred"; } //articulateContext.Context = ctx; toBuild.Context = articulateContext; } return(toBuild); }
public IBuildIntention <IImplementationDefinition> GetBuildIntention(IConversionContext context) { var(toBuild, maker) = ImplementationDefinition.Create(); return(new BuildIntention <IImplementationDefinition>(toBuild, () => { var contextMember = ContextDefinition.Convert(context); maker.Build( OutputType.Is1OrThrow().Convert(context), contextMember, ParameterDefinition.Convert(context), Scope.GetValue().Convert(context), MethodBody.GetValue().Select(x => x.Is1OrThrow().GetValue().ConvertElementOrThrow(context)).ToArray(), StaticInitialzers.Select(x => x.ConvertElementOrThrow(context)).ToArray(), Model.Instantiated.Scope.CreateAndBuild(new IsStatic[] { new IsStatic(contextMember, false) })); })); }
public IEnumerable <IError> Validate() { foreach (var error in OutputType.SwitchReturns(x => x.Validate(), x => new[] { x })) { yield return(error); } foreach (var error in ContextDefinition.Validate()) { yield return(error); } foreach (var error in ParameterDefinition.Validate()) { yield return(error); } foreach (var error in Scope.GetValue().Validate()) { yield return(error); } foreach (var line in MethodBody.GetValue().OfType <IIsDefinately <IBox <IFrontendCodeElement> > >().Select(x => x.Value)) { foreach (var error in line.GetValue().Validate()) { yield return(error); } } foreach (var error in MethodBody.GetValue().OfType <IIsDefinately <IError> >().Select(x => x.Value)) { yield return(error); } foreach (var line in StaticInitialzers) { foreach (var error in line.Validate()) { yield return(error); } } }
public DataInputOutputSerde[] GetContextPartitionKeyBindings( ContextDefinition contextDefinition) { return null; }