public OutputGroupRepositoryTest()
 {
     this.group1     = new OutputGroup("test1");
     this.group2     = new OutputGroup("test2");
     this.group3     = new OutputGroup("test3");
     this.repository = new OutputGroupRepository();
 }
Exemplo n.º 2
0
 public CompilableElementCollectorFactory(
     SectorElementCollection sectorElements,
     OutputGroupRepository outputGroups
     )
 {
     this.sectorElements = sectorElements;
     this.outputGroups   = outputGroups;
 }
 public InputFileListFactoryTest()
 {
     this.outputGroup           = new OutputGroup("test");
     this.outputGroups          = new OutputGroupRepository();
     this.sectorDataFileFactory = SectorDataFileFactoryFactory.Make(new List <string>());
     this.inclusionRules        = new ConfigInclusionRules();
     inclusionRules.AddMiscInclusionRule(
         new FolderInclusionRule(
             ConvertPath("_TestData/InputFileListFactory"),
             false,
             InputDataType.ESE_AGREEMENTS,
             this.outputGroup
             )
         );
 }
        public static InputFileList CreateFromInclusionRules(
            SectorDataFileFactory dataFileFactory,
            ConfigInclusionRules config,
            OutputGroupRepository outputGroups
            )
        {
            InputFileList fileList = new InputFileList();

            foreach (IInclusionRule rule in config)
            {
                OutputGroup   group     = rule.GetOutputGroup();
                List <string> filePaths = new();
                foreach (AbstractSectorDataFile file in rule.GetFilesToInclude(dataFileFactory))
                {
                    fileList.Add(file);
                    filePaths.Add(file.FullPath);
                }

                outputGroups.AddGroupWithFiles(group, filePaths);
            }
            return(fileList);
        }
 public PositionsCollector(SectorElementCollection sectorElements, OutputGroupRepository repository)
 {
     this.sectorElements = sectorElements;
     this.repository     = repository;
 }
Exemplo n.º 6
0
 public AirspaceCollector(SectorElementCollection sectorElements, OutputGroupRepository outputGroups)
 {
     this.sectorElements = sectorElements;
     this.outputGroups   = outputGroups;
 }
        public int Compile()
        {
            events.AddEvent(new ComplilationStartedEvent());

            CompilerArgumentsValidator.Validate(events, arguments);
            if (events.HasFatalError())
            {
                events.AddEvent(new CompilationFinishedEvent(false));
                return(1);
            }

            // Parse all the config files
            OutputGroupRepository outputGroups = new OutputGroupRepository();

            ConfigInclusionRules config;

            try
            {
                events.AddEvent(new CompilationMessage("Loading config files"));
                config = ConfigFileLoaderFactory.Make().LoadConfigFiles(arguments.ConfigFiles, arguments);
            } catch (ConfigFileInvalidException e)
            {
                events.AddEvent(new CompilationMessage(e.Message));
                events.AddEvent(new CompilationFinishedEvent(false));
                return(1);
            }

            // Parse all the input files and create elements
            SectorElementCollection sectorElements = new SectorElementCollection();
            DataParserFactory       parserFactory  = new DataParserFactory(sectorElements, events);
            InputFileList           fileList;

            try
            {
                events.AddEvent(new CompilationMessage("Building input file list"));
                fileList = InputFileListFactory.CreateFromInclusionRules(
                    new SectorDataFileFactory(new InputFileStreamFactory()),
                    config,
                    outputGroups
                    );
            }
            catch (System.Exception exception)
            {
                events.AddEvent(new CompilationMessage(exception.Message));
                events.AddEvent(new CompilationFinishedEvent(false));
                return(1);
            }

            events.AddEvent(new CompilationMessage("Injecting pre-parse static data"));
            RunwayCentrelineInjector.InjectRunwayCentrelineData(sectorElements);

            events.AddEvent(new CompilationMessage("Parsing input files"));
            foreach (AbstractSectorDataFile dataFile in fileList)
            {
                parserFactory.GetParserForFile(dataFile).ParseData(dataFile);
            }

            if (events.HasFatalError())
            {
                events.AddEvent(new CompilationFinishedEvent(false));
                return(1);
            }

            // There's some static data we need to inject to the collection for adjacent airports...
            events.AddEvent(new CompilationMessage("Injecting post-parse static data"));
            AdjacentAirportsInjector.InjectAdjacentAirportsData(sectorElements);


            // Now all the data is loaded, validate that there are no broken references etc.
            if (arguments.ValidateOutput)
            {
                events.AddEvent(new CompilationMessage("Validating data"));
                OutputValidator.Validate(sectorElements, arguments, events);
                if (events.HasFatalError())
                {
                    events.AddEvent(new CompilationFinishedEvent(false));
                    return(1);
                }
            }
            else
            {
                events.AddEvent(new CompilationMessage("Skipping output validation"));
            }

            // Generate the output
            OutputGenerator generator = new OutputGenerator(
                sectorElements,
                outputGroups,
                new CompilableElementCollectorFactory(sectorElements, outputGroups)
                );

            foreach (AbstractOutputFile output in arguments.OutputFiles)
            {
                events.AddEvent(new CompilationMessage($"Generating {output.GetFileDescriptor()} output"));
                generator.GenerateOutput(output);
            }

            events.AddEvent(new CompilationFinishedEvent(true));
            return(0);
        }