Example #1
0
 public ProcessOperations(
     PomReader pomReader,
     BpmnReader bpmnReader,
     FfdReader ffdReader,
     ProcessFlowJsonReader processFlowJsonReader,
     ProcessJsonReader processJsonReader,
     StatusTableReader statusTableReader)
 {
     PomReader             = pomReader;
     BpmnReader            = bpmnReader;
     FfdReader             = ffdReader;
     ProcessFlowJsonReader = processFlowJsonReader;
     ProcessJsonReader     = processJsonReader;
     StatusTableReader     = statusTableReader;
 }
Example #2
0
        static Factory()
        {
            FileSystem            = new FileSystem(Logger);
            ImportExport          = new ImportExport(PrettyPrinter, PomReader, Logger, FileSystem);
            ProjectRename         = new ProjectRename(ImportExport);
            ProcessFlowJsonReader = new ProcessFlowJsonReader(PrettyPrinter);

            var verifications = new List <IStructuralOperation>();

            verifications.Add(new RootPomOperations(PomReader, LogicLIbraryReader));
            verifications.Add(new ProjectOperations(PomReader, ControllerJsonReader, FactoryFrameworkReader, ProjectJsonReader));
            verifications.Add(
                new ProcessOperations(
                    PomReader,
                    BpmnReader,
                    FfdReader,
                    ProcessFlowJsonReader,
                    ProcessJsonReader,
                    StatusTableReader));

            AllProjectOperations = new AllProjectOperations(verifications);
        }
Example #3
0
        public void VerifyFlow(VerificationResult result, DirectoryInfo projectDir, Dependency flow, Project project)
        {
            var pom             = "pom.xml";
            var flowName        = flow.ArtifactId.ToLower();
            var bpmn            = flowName + ".bpmn";
            var ffd             = flowName + ".ffd";
            var flowsJson       = flowName + ".json";
            var processJson     = flowName + "_process.json";
            var operationStatus = "operation-status.fdt";
            var workplaceStatus = "workplace-status.fdt";

            Project pomResult           = null;
            List <LogicComponent> flows = null;

            if (!File.Exists(Path.Combine(projectDir.FullName, pom)))
            {
                result.Error(flowName + " " + pom + " is missing");
            }
            else
            {
                var pomPath = Path.Combine(projectDir.FullName, pom);
                pomResult = PomReader.Parse(File.ReadAllText(pomPath));
                result.ProvideDependency(pom, pomResult);
                result.ProvideFlow(pomPath, new FlowConfiguration(pomResult.GroupId, pomResult.ArtifactId, pomResult.Version, "", ""));

                foreach (var dependency in pomResult.Dependencies)
                {
                    result.RequireDependency(pomPath, dependency);
                }
            }

            if (!File.Exists(Path.Combine(projectDir.FullName, bpmn)))
            {
                result.Error(flowName + " " + bpmn + " is missing");
            }
            else
            {
                var bpmnResult = BpmnReader.Parse(File.ReadAllText(Path.Combine(projectDir.FullName, bpmn)));
                foreach (var components in bpmnResult.LogicComponents)
                {
                    if (IgnoreComponent(components))
                    {
                        continue;
                    }

                    result.RequireLogicComponent(bpmn, components);
                }

                flows = bpmnResult.LogicComponents;

                if (pomResult != null && !bpmnResult.Project.ArtifactId.Equals(pomResult.ArtifactId))
                {
                    result.Error(bpmn + " artifact ID doesn't match pom artifact ID");
                }

                foreach (var dependency in bpmnResult.Project.Dependencies)
                {
                    result.RequireDependency(bpmn, dependency);
                }
            }

            if (!File.Exists(Path.Combine(projectDir.FullName, ffd)))
            {
                result.Error(flowName + " " + ffd + " is missing");
            }
            else
            {
                var flowResult = FfdReader.Parse(File.ReadAllText(Path.Combine(projectDir.FullName, ffd)));
                foreach (var components in flowResult.LogicComponents)
                {
                    if (IgnoreComponent(components))
                    {
                        continue;
                    }

                    result.RequireLogicComponent(ffd, components);
                }

                if (pomResult != null && !flowResult.Project.ArtifactId.Equals(pomResult.ArtifactId))
                {
                    result.Error(ffd + " artifact ID doesn't match pom artifact ID");
                }

                foreach (var dependency in flowResult.Project.Dependencies)
                {
                    result.RequireDependency(ffd, dependency);
                }
            }

            if (!File.Exists(Path.Combine(projectDir.FullName, flowsJson)))
            {
                result.Error(flowName + " " + flowsJson + " is missing");
            }
            else
            {
                var flowResult = ProcessFlowJsonReader.Parse(File.ReadAllText(Path.Combine(projectDir.FullName, flowsJson)));
                foreach (var components in flowResult.LogicComponents)
                {
                    result.RequireLogicComponent(bpmn, components);
                }

                if (flows != null)
                {
                    foreach (var missMatch in flows
                             .Where(f => !flowResult.LogicComponents.Contains(f))
                             .Where(m => !m.Name.EndsWith("status")))
                    {
                        result.Error(bpmn + " doesn't match " + missMatch);
                    }
                }

                foreach (var dependency in flowResult.Project.Dependencies)
                {
                    result.RequireDependency(flowsJson, dependency);
                }
            }

            if (!File.Exists(Path.Combine(projectDir.FullName, processJson)))
            {
                result.Error(flowName + " " + processJson + " is missing");
            }
            else
            {
                var projectResult = ProcessJsonReader.Parse(File.ReadAllText(Path.Combine(projectDir.FullName, processJson)));
                if (pomResult != null && !projectResult.ArtifactId.Equals(pomResult.ArtifactId))
                {
                    result.Error(processJson + " artifact ID doesn't match pom artifact ID");
                }

                foreach (var dependency in projectResult.Dependencies)
                {
                    result.RequireDependency(processJson, dependency);
                }
            }

            if (flowName == "core-process")
            {
                if (!File.Exists(Path.Combine(projectDir.FullName, workplaceStatus)))
                {
                    result.Error(flowName + " " + workplaceStatus + " is missing");
                }
                else
                {
                    var statusTable = StatusTableReader.Parse(File.ReadAllText(Path.Combine(projectDir.FullName, workplaceStatus)));
                    foreach (var status in statusTable)
                    {
                        result.RequireStatusDefinition(workplaceStatus, status);
                    }
                }

                if (File.Exists(Path.Combine(projectDir.FullName, operationStatus)))
                {
                    var statusTable = StatusTableReader.Parse(File.ReadAllText(Path.Combine(projectDir.FullName, operationStatus)));
                    foreach (var status in statusTable)
                    {
                        result.RequireStatusDefinition(workplaceStatus, status);
                    }
                }
            }
        }
Example #4
0
        public void IncrementFlowVersion(DirectoryInfo projectDir, Dependency flow, Project project)
        {
            var pom       = "pom.xml";
            var flowName  = flow.ArtifactId.ToLower();
            var bpmn      = flowName + ".bpmn";
            var flowsJson = flowName + ".json";

            if (File.Exists(Path.Combine(projectDir.FullName, pom)))
            {
                VersionIncrement.ReplaceFileContent(Path.Combine(projectDir.FullName, pom), c => PomReader.IncrementVersion(c));
            }

            if (File.Exists(Path.Combine(projectDir.FullName, bpmn)))
            {
                VersionIncrement.ReplaceFileContent(Path.Combine(projectDir.FullName, bpmn), c => BpmnReader.IncrementVersion(c));
            }

            if (File.Exists(Path.Combine(projectDir.FullName, flowsJson)))
            {
                VersionIncrement.ReplaceFileContent(Path.Combine(projectDir.FullName, flowsJson), c => ProcessFlowJsonReader.IncrementVersion(c));
            }
        }