Beispiel #1
0
 public ProjectOperations(PomReader pomReader, ControllerJsonReader controllerJsonReader, FactoryFrameworkReader factoryFrameworkReader, ProjectJsonReader projectJsonReader)
 {
     PomReader              = pomReader;
     ControllerJsonReader   = controllerJsonReader;
     FactoryFrameworkReader = factoryFrameworkReader;
     ProjectJsonReader      = projectJsonReader;
 }
        protected override void Execute(byte[] encodedFile)
        {
            var result = new ProjectJsonReader().ReadDependencies(encodedFile);

            result.Count.Should().Be(2);
            result.Should().BeEquivalentTo("Antlr", "bootstrap");
        }
        public IAmeSession Generate()
        {
            ResourceLoader loader = ResourceLoader.Instance;

            IList <Project>   projects      = new List <Project>();
            ProjectJsonReader projectReader = new ProjectJsonReader();

            foreach (string projectPath in this.OpenedProjectFiles)
            {
                try
                {
                    projects.Add(loader.Load <Project>(projectPath, projectReader));
                }
                catch (Exception e)
                {
                    StringBuilder builder = new StringBuilder();
                    builder.Append("Error reading project ");
                    builder.Append(projectPath);
                    builder.Append(" ");
                    builder.Append(e.Message);
                    Console.Error.WriteLine(builder);
                }
            }

            IList <Map>   maps      = new List <Map>();
            MapJsonReader mapReader = new MapJsonReader();

            foreach (string mapPath in this.OpenedMapFiles)
            {
                try
                {
                    maps.Add(loader.Load <Map>(mapPath, mapReader));
                }
                catch (Exception e)
                {
                    StringBuilder builder = new StringBuilder();
                    builder.Append("Error reading map ");
                    builder.Append(mapPath);
                    builder.Append(" ");
                    builder.Append(e.Message);
                    Console.Error.WriteLine(builder);
                }
            }
            // TODO Bug: the current map index is incorrect when a map editor is closed.
            // TODO store the current tileset
            AmeSession session = new AmeSession(maps, projects, this.WorkspaceDirectory, this.LastTilesetDirectory, this.LastMapDirectory, this.Version);

            if (session.MapCount > 0)
            {
                session.CurrentMap.Value = maps[this.CurrentMapIndex];
                if (session.CurrentMap.Value.Tilesets.Count > 0)
                {
                    session.CurrentTileset.Value = session.CurrentMap.Value.Tilesets[0];
                }
                session.CurrentProject = session.CurrentMap.Value.Project;
            }

            return(session);
        }
        public void ParseTest()
        {
            var project      = new ProjectJsonReader().Parse(Content);
            var dependencies = new Dependency("com.forcam.na.common-modules", "common-modules.library", "11.3");
            var expected     = new Project("?", "FF-RD-07", "?");

            Assert.AreEqual(project, expected);
        }
        public void RaiseNotification(DependencyObject parent)
        {
            OpenFileDialog openDialog = new OpenFileDialog();

            openDialog.Title            = "Open a Project";
            openDialog.InitialDirectory = this.session.LastTilesetDirectory.Value;
            if (openDialog.ShowDialog().Value)
            {
                string dialogPath = openDialog.FileName;
                if (File.Exists(dialogPath))
                {
                    ProjectJsonReader reader  = new ProjectJsonReader();
                    ResourceLoader    loader  = ResourceLoader.Instance;
                    Project           project = loader.Load <Project>(dialogPath, reader);

                    this.session.Projects.Add(project);
                }
            }
        }
Beispiel #6
0
        public void Verify(VerificationResult result, DirectoryInfo workspace, Project project)
        {
            var projectDir = Path.Combine(workspace.FullName, project.FlatName);

            if (!Directory.Exists(projectDir))
            {
                result.Error(project.FlatName + "is missing");
                return;
            }

            var pom = "pom.xml";
            var factoryFramework = "factoryFramework.xml";
            var controllerJson   = project.ArtifactId + "_controller.json";
            var projectJson      = project.ArtifactId + "_project.json";

            if (!File.Exists(Path.Combine(projectDir, projectJson)))
            {
                result.Error("project " + projectJson + " is missing");
            }
            else
            {
                var jsonProject = ProjectJsonReader.Parse(File.ReadAllText(Path.Combine(projectDir, projectJson)));
                if (!jsonProject.ArtifactId.Equals(project.ArtifactId, StringComparison.InvariantCultureIgnoreCase))
                {
                    result.Error("project " + projectJson + " doesn't match project definition");
                }

                if (!jsonProject.DependentLogicLibrary.Version.Equals(project.DependentLogicLibrary.Version))
                {
                    result.Error("project " + projectJson + " has a different logic library version");
                }
            }

            List <FlowConfiguration> flows = null;

            if (!File.Exists(Path.Combine(projectDir, controllerJson)))
            {
                result.Error("project " + controllerJson + " is missing");
            }
            else
            {
                flows = ControllerJsonReader.Parse(File.ReadAllText(Path.Combine(projectDir, controllerJson)));
                foreach (var flow in flows)
                {
                    result.RequireFlow(controllerJson, flow);
                    if (!string.IsNullOrEmpty(flow.BookingType))
                    {
                        result.RequireBookingType(controllerJson, flow.BookingType);
                    }
                }
            }

            if (!File.Exists(Path.Combine(projectDir, factoryFramework)))
            {
                result.Error("project " + factoryFramework + " is missing");
            }
            else
            {
                var factoryResults = FactoryFrameworkReader.Parse(File.ReadAllText(Path.Combine(projectDir, factoryFramework)));
                foreach (var bookingType in factoryResults.BookingTypes)
                {
                    result.ProvideBookingType(factoryFramework, bookingType);
                }

                foreach (var statusDefinition in factoryResults.StatusDefinitions)
                {
                    result.ProvideStatusDefinition(factoryFramework, statusDefinition);
                }

                foreach (var flow in factoryResults.Flows)
                {
                    result.RequireFlow(controllerJson, flow);
                }

                if (flows != null)
                {
                    if (flows.Count != factoryResults.Flows.Count)
                    {
                        result.Error("project " + factoryFramework + " number of flows don't match with " + flows);
                    }

                    foreach (var missMatch in flows.Where(f => !factoryResults.Flows.Contains(f)))
                    {
                        result.Error("project flow doesn't match " + missMatch);
                    }
                }
            }

            if (!File.Exists(Path.Combine(projectDir, pom)))
            {
                result.Error("project " + pom + " is missing");
            }
            else
            {
                var projectPom = PomReader.Parse(new FileInfo(Path.Combine(projectDir, pom)));
                result.ProvideDependency(pom, projectPom);

                foreach (var dependency in projectPom.Dependencies)
                {
                    result.RequireDependency(projectPom.FlatName, dependency);
                }
            }
        }