Beispiel #1
0
        private EPStatement CompileDeploy(
            string epl)
        {
            var args = new CompilerArguments();

            args.Path.Add(_runtime.RuntimePath);
            args.Options.AccessModifierNamedWindow = env => NameAccessModifier.PUBLIC;
            args.Configuration.Compiler.ByteCode.AllowSubscriber = true;

            var compiled   = EPCompilerProvider.Compiler.Compile(epl, args);
            var deployment = _runtime.DeploymentService.Deploy(compiled);

            return(deployment.Statements[0]);
        }
Beispiel #2
0
        private static EPCompiled CompileRuntimePath(
            RegressionEnvironment env,
            string moduleName,
            string query)
        {
            CompilerArguments args = new CompilerArguments();

            args.Options.ModuleUses = (_) => new HashSet <string>()
            {
                moduleName
            };
            args.Path.Add(env.Runtime.RuntimePath);
            return(env.Compiler.CompileQuery(query, args));
        }
Beispiel #3
0
        public EPCompiled Compile(
            bool soda,
            string epl,
            CompilerArguments arguments)
        {
            if (!soda) {
                Compile(epl, arguments);
            }

            var copy = EplToModel(epl);
            Assert.AreEqual(epl, copy.ToEPL());
            arguments.Configuration = Configuration;
            return Compile(copy, arguments);
        }
Beispiel #4
0
 public static EPDeployment CompileDeploy(
     EPRuntime epService,
     string epl)
 {
     try {
         var args = new CompilerArguments(epService.ConfigurationDeepCopy);
         args.Path.Add(epService.RuntimePath);
         var compiled = EPCompilerProvider.Compiler.Compile(epl, args);
         return(epService.DeploymentService.Deploy(compiled));
     }
     catch (Exception ex) {
         throw new EPRuntimeException(ex);
     }
 }
        public void Validate(SectorElementCollection sectorElements, CompilerArguments args, IEventLogger events)
        {
            foreach (Airport airport in sectorElements.Airports)
            {
                if (airport.Icao == sectorElements.Info.Airport.AirportIcao)
                {
                    return;
                }
            }

            events.AddEvent(
                new ValidationRuleFailure("Invalid airport in INFO definition", sectorElements.Info.Airport)
                );
        }
Beispiel #6
0
        private void RunSampleFireAndForgetQuery(EPRuntime runtime)
        {
            var fireAndForget = "select * from MySampleWindow where key1 = 'sample1' and key2 = 'sample2'"; // see values in SampleVirtualDataWindowIndex
            var compilerArgs  = new CompilerArguments();

            compilerArgs.Path.Add(runtime.RuntimePath);

            var compiled = EPCompilerProvider.Compiler.CompileQuery(fireAndForget, compilerArgs);
            var result   = runtime.FireAndForgetService.ExecuteQuery(compiled);

            Log.Info("Fire-and-forget query returned: " + result.Array[0].Get("key1") + " and " + result.Array[0].Get("key2"));

            // For assertions against expected results please see the regression test suite
        }
Beispiel #7
0
        public void Validate(SectorElementCollection sectorElements, CompilerArguments args, IEventLogger events)
        {
            List <string> sectors = sectorElements.Sectors.Select(sector => sector.Name).ToList();

            foreach (CoordinationPoint point in sectorElements.CoordinationPoints)
            {
                if (!sectors.Contains(point.FromSector))
                {
                    string message =
                        $"Invalid FROM sector {point.FromSector} for coordination point: {point.GetCompileData(sectorElements)}";
                    events.AddEvent(new ValidationRuleFailure(message, point));
                }
            }
        }
        public static SectorFileCompiler Create(CompilerArguments arguments, List <IEventObserver> eventObservers)
        {
            EventTracker events = new EventTracker();

            foreach (IEventObserver observer in eventObservers)
            {
                events.AddObserver(observer);
            }

            return(new SectorFileCompiler(
                       arguments,
                       events
                       ));
        }
Beispiel #9
0
 public void Validate(SectorElementCollection sectorElements, CompilerArguments args, IEventLogger events)
 {
     foreach (Region region in sectorElements.Regions)
     {
         foreach (RegionPoint point in region.Points)
         {
             if (point.Colour != null && !ColourValidator.ColourValid(sectorElements, point.Colour))
             {
                 string errorMessage = $"Invalid colour value {point.Colour} for region {region.Name}";
                 events.AddEvent(new ValidationRuleFailure(errorMessage, point));
             }
         }
     }
 }
Beispiel #10
0
 public void Validate(SectorElementCollection sectorElements, CompilerArguments args, IEventLogger events)
 {
     foreach (GroundNetwork groundNetwork in sectorElements.GroundNetworks)
     {
         foreach (GroundNetworkRunwayExit exit in groundNetwork.RunwayExits)
         {
             if (!RunwayValid(sectorElements, exit.Runway, groundNetwork.Airport))
             {
                 string message = $"Invalid ground network runway {groundNetwork.Airport}/{exit.Runway}";
                 events.AddEvent(new ValidationRuleFailure(message, exit));
                 break;
             }
         }
     }
 }
 public void Validate(SectorElementCollection sectorElements, CompilerArguments args, IEventLogger events)
 {
     foreach (SidStarRoute sid in sectorElements.SidRoutes)
     {
         foreach (RouteSegment segment in sid.Segments)
         {
             if (segment.Colour != null && !ColourValidator.ColourValid(sectorElements, segment.Colour))
             {
                 string errorMessage =
                     $"Invalid colour value {segment.Colour} in route segment for SID {sid.Identifier}";
                 events.AddEvent(new ValidationRuleFailure(errorMessage, segment));
             }
         }
     }
 }
Beispiel #12
0
        public void Validate(SectorElementCollection sectorElements, CompilerArguments args, IEventLogger events)
        {
            List <string> checkedFixes = new List <string>();

            foreach (Fix fix in sectorElements.Fixes)
            {
                if (checkedFixes.Contains(GetFixKey(fix)))
                {
                    events.AddEvent(new ValidationRuleFailure("Duplicate fix found: " + fix.Identifier, fix));
                    continue;
                }

                checkedFixes.Add(GetFixKey(fix));
            }
        }
Beispiel #13
0
            public void Run(RegressionEnvironment env)
            {
                MyUserObjectResolver.Contexts.Clear();
                var args = new CompilerArguments(env.Configuration);
                args.Options.StatementUserObject = (new MyUserObjectResolver()).GetValue;
                var epl = "@Name('s0') select * from SupportBean";
                env.Compile(epl, args);

                var ctx = MyUserObjectResolver.Contexts[0];
                Assert.AreEqual(epl, ctx.EplSupplier.Invoke());
                Assert.AreEqual("s0", ctx.StatementName);
                Assert.AreEqual(null, ctx.ModuleName);
                Assert.AreEqual(1, ctx.Annotations.Length);
                Assert.AreEqual(0, ctx.StatementNumber);
            }
        public void Validate(SectorElementCollection sectorElements, CompilerArguments args, IEventLogger events)
        {
            List <string> coloursProcessed = new List <string>();

            foreach (Colour colour in sectorElements.Colours)
            {
                if (coloursProcessed.Contains(colour.Name.ToLower()))
                {
                    events.AddEvent(new ValidationRuleFailure("Duplicate colourm definition " + colour.Name, colour));
                    continue;
                }

                coloursProcessed.Add(colour.Name.ToLower());
            }
        }
        public void Validate(SectorElementCollection sectorElements, CompilerArguments args, IEventLogger events)
        {
            List <string> existingAirports = new List <string>();

            foreach (Airport airport in sectorElements.Airports)
            {
                if (existingAirports.Contains(airport.Icao))
                {
                    events.AddEvent(new ValidationRuleFailure("Duplicate airport " + airport.Icao, airport));
                    continue;
                }

                existingAirports.Add(airport.Icao);
            }
        }
 private static EPDeployment CreateStmt(
     RegressionEnvironment env,
     string epl)
 {
     try {
         var configuration = env.Runtime.ConfigurationDeepCopy;
         var args = new CompilerArguments(configuration);
         args.Path.Add(env.Runtime.RuntimePath);
         var compiled = env.Compiler.Compile(epl, args);
         return env.Runtime.DeploymentService.Deploy(compiled);
     }
     catch (Exception ex) {
         throw new EPRuntimeException(ex);
     }
 }
 private static void TryInvalidCompileWConfigure(
     RegressionEnvironment env,
     Consumer<Configuration> configurer,
     string epl,
     string message)
 {
     try {
         var configuration = env.MinimalConfiguration();
         configurer.Invoke(configuration);
         var args = new CompilerArguments(configuration);
         env.Compiler.Compile(epl, args);
     }
     catch (EPCompileException ex) {
         SupportMessageAssertUtil.AssertMessage(ex, message);
     }
 }
Beispiel #18
0
        public void Validate(SectorElementCollection sectorElements, CompilerArguments args, IEventLogger events)
        {
            foreach (SidStar sidStar in sectorElements.SidStars)
            {
                bool airportExists = sectorElements.Airports
                                     .Count(airport => sidStar.Airport == airport.Icao) != 0;

                if (!airportExists)
                {
                    string errorMessage =
                        $"Airport {sidStar.Airport} is not valid for {sidStar.Type}/{sidStar.Identifier}";

                    events.AddEvent(new ValidationRuleFailure(errorMessage, sidStar));
                }
            }
        }
        /**
         * Check there's valid format and create a date replacement token
         */
        private void ProcessDateReplacement(CompilerArguments arguments, JObject replacement, string tokenToReplace)
        {
            JToken formatToken = replacement.SelectToken("format");

            if (formatToken == null)
            {
                throw new ConfigFileInvalidException($"Missing date format in replace");
            }

            if (formatToken.Type != JTokenType.String)
            {
                throw new ConfigFileInvalidException($"Invalid date format in replace, must be a string");
            }

            arguments.TokenReplacers.Add(new TokenDateReplacer(tokenToReplace, formatToken.ToString()));
        }
Beispiel #20
0
 public void Validate(SectorElementCollection sectorElements, CompilerArguments args, IEventLogger events)
 {
     foreach (Sector sector in sectorElements.Sectors)
     {
         foreach (SectorActive active in sector.Active)
         {
             if (!RunwayValid(sectorElements, active.Runway, active.Airfield))
             {
                 string message =
                     $"Invalid ACTIVE runway {active.Airfield}/{active.Runway} on sector {sector.Name}";
                 events.AddEvent(new ValidationRuleFailure(message, active));
                 break;
             }
         }
     }
 }
        public void Validate(SectorElementCollection sectorElements, CompilerArguments args, IEventLogger events)
        {
            List <string> keys = new List <string>();

            foreach (SidStar sidStar in sectorElements.SidStars)
            {
                string sidStarKey = GetKey(sidStar);
                if (keys.Contains(sidStarKey))
                {
                    events.AddEvent(new ValidationRuleFailure("Duplicate SID/STAR " + sidStarKey, sidStar));
                    continue;
                }

                keys.Add(sidStarKey);
            }
        }
Beispiel #22
0
 private static void TryInvalidCompileFAF(
     RegressionEnvironment env,
     RegressionPath path,
     string faf,
     string expected)
 {
     try {
         var args = new CompilerArguments(env.Configuration);
         args.Path.AddAll(path.Compileds);
         env.Compiler.CompileQuery(faf, args);
         Assert.Fail();
     }
     catch (EPCompileException ex) {
         AssertMessage(ex, expected);
     }
 }
Beispiel #23
0
        public EPCompiled Compile(
            string epl,
            CompilerArguments arguments)
        {
            if (arguments == null) {
                arguments = new CompilerArguments(new Configuration());
            }

            using (arguments.Configuration.Container.EnterContextualReflection()) {
                try {
                    var module = EPLModuleUtil.ParseInternal(epl, null);
                    IList<Compilable> compilables = new List<Compilable>();
                    foreach (var item in module.Items.Where(m => !m.IsCommentOnly)) {
                        var stmtEpl = item.Expression;
                        compilables.Add(new CompilableEPL(stmtEpl));
                    }

                    // determine module name
                    var moduleName = DetermineModuleName(arguments.Options, module);
                    var moduleUses = DetermineModuleUses(moduleName, arguments.Options, module);

                    // get compile services
                    var compileTimeServices = GetCompileTimeServices(arguments, moduleName, moduleUses, false);
                    AddModuleImports(module.Imports, compileTimeServices);

                    // compile
                    return CompilerHelperModuleProvider.Compile(
                        compilables,
                        moduleName,
                        new EmptyDictionary<ModuleProperty, object>(),
                        compileTimeServices,
                        arguments.Options);
                }
                catch (EPCompileException) {
                    throw;
                }
                catch (ParseException t) {
                    throw new EPCompileException(
                        "Failed to parse: " + t.Message,
                        t,
                        new EmptyList<EPCompileExceptionItem>());
                }
                catch (Exception ex) {
                    throw new EPCompileException(ex.Message, ex, new EmptyList<EPCompileExceptionItem>());
                }
            }
        }
        public void Validate(SectorElementCollection sectorElements, CompilerArguments args, IEventLogger events)
        {
            List <string> controllers = sectorElements.EsePositions.Select(position => position.Identifier).ToList();

            foreach (Sector sector in sectorElements.Sectors)
            {
                foreach (SectorGuest guest in sector.Guests)
                {
                    if (!controllers.Contains(guest.Controller))
                    {
                        string message = $"Invalid GUEST position {guest.Controller} on sector {sector.Name}";
                        events.AddEvent(new ValidationRuleFailure(message, guest));
                        break;
                    }
                }
            }
        }
Beispiel #25
0
        public void SyntaxValidate(
            Module module,
            CompilerArguments arguments)
        {
            if (arguments == null) {
                arguments = new CompilerArguments(new Configuration());
            }

            // determine module name
            var moduleName = DetermineModuleName(arguments.Options, module);
            var moduleUses = DetermineModuleUses(moduleName, arguments.Options, module);

            var moduleCompileTimeServices = GetCompileTimeServices(arguments, moduleName, moduleUses, false);

            var statementNumber = 0;
            try {
                foreach (var item in module.Items) {
                    var services = new StatementCompileTimeServices(statementNumber, moduleCompileTimeServices);
                    if (item.IsCommentOnly) {
                        continue;
                    }

                    if (item.Expression != null && item.Model != null) {
                        throw new EPCompileException(
                            "Module item has both an EPL expression and a statement object model");
                    }

                    if (item.Expression != null) {
                        CompilerHelperSingleEPL.ParseCompileInlinedClassesWalk(new CompilableEPL(item.Expression), services);
                    }
                    else if (item.Model != null) {
                        CompilerHelperSingleEPL.ParseCompileInlinedClassesWalk(new CompilableSODA(item.Model), services);
                        item.Model.ToEPL();
                    }
                    else {
                        throw new EPCompileException(
                            "Module item has neither an EPL expression nor a statement object model");
                    }

                    statementNumber++;
                }
            }
            catch (Exception ex) {
                throw new EPCompileException(ex.Message, ex);
            }
        }
Beispiel #26
0
        public void Validate(SectorElementCollection sectorElements, CompilerArguments args, IEventLogger events)
        {
            List <string> positions = sectorElements.EsePositions.Select(position => position.Identifier).ToList();

            foreach (Sector sector in sectorElements.Sectors)
            {
                foreach (string position in sector.Owners.Owners)
                {
                    if (!positions.Contains(position))
                    {
                        string message = $"Invalid OWNER position {position} on sector {sector.Name}";
                        events.AddEvent(new ValidationRuleFailure(message, sector));
                        break;
                    }
                }
            }
        }
 public void Validate(SectorElementCollection sectorElements, CompilerArguments args, IEventLogger events)
 {
     foreach (SidStar sidStar in sectorElements.SidStars)
     {
         foreach (string waypoint in sidStar.Route)
         {
             if (!RoutePointValidator.ValidateEseSidStarPoint(waypoint, sectorElements))
             {
                 string message =
                     $"Invalid waypoint {waypoint} on {sidStar.Type} {sidStar.Airport}/{sidStar.Identifier}";
                 events.AddEvent(
                     new ValidationRuleFailure(message, sidStar)
                     );
             }
         }
     }
 }
Beispiel #28
0
 public static void TryInvalidCompileGraph(
     EPRuntime epService,
     string graph,
     string expected)
 {
     try {
         var args = new CompilerArguments(epService.ConfigurationDeepCopy);
         args.Path.Add(epService.RuntimePath);
         EPCompilerProvider.Compiler.Compile(graph, args);
         Assert.Fail();
     }
     catch (EPCompileException ex) {
         if (!ex.Message.StartsWith(expected))
         {
             Assert.AreEqual(expected, ex.Message);
         }
     }
 }
        public void Validate(SectorElementCollection sectorElements, CompilerArguments args, IEventLogger events)
        {
            List <string> airports = sectorElements.Airports.Select(airport => airport.Icao).ToList();

            airports.Add("000A");
            foreach (Sector sector in sectorElements.Sectors)
            {
                foreach (SectorActive active in sector.Active)
                {
                    if (!airports.Contains(active.Airfield))
                    {
                        string message = $"Invalid ACTIVE airport {active.Airfield} on sector {sector.Name}";
                        events.AddEvent(new ValidationRuleFailure(message, active));
                        break;
                    }
                }
            }
        }
        public void Validate(SectorElementCollection sectorElements, CompilerArguments args, IEventLogger events)
        {
            List <string> airports = sectorElements.Airports
                                     .Select(airport => airport.Icao)
                                     .ToList();

            foreach (Runway runway in sectorElements.Runways)
            {
                if (!airports.Contains(runway.AirfieldIcao))
                {
                    string message =
                        $"Runway {runway.FirstIdentifier}/{runway.ReverseIdentifier} ({runway.AirfieldIcao}) does not match up to a defined airport";

                    events.AddEvent(
                        new ValidationRuleFailure(message, runway)
                        );
                }
            }
        }