public void Should_Generate_Classes_method_When_XsdReference_is_present() { ConfigurationApp.SaveProperty("IsXmlParserHelperAlreadyGenerated", "false"); var generatedClasses = xmlParseActivityBuilder.GenerateClassesToGenerate(this.activity, null); Assert.AreEqual(2, generatedClasses.Count); }
public string ParsePackageName(string fileName) { var initialProjectPath = ConfigurationApp.GetProperty(MainClass.ProjectDirectory) + DefaultsubstvarDirectory; var path = fileName.Replace(Defaultsubstvar, String.Empty); path = path.Remove(path.Length - 1, 1); path = path.Replace("/", "."); path = path.Replace("\\", "."); if (initialProjectPath != null) { initialProjectPath = initialProjectPath.Replace("/", "."); initialProjectPath = initialProjectPath.Replace("\\", "."); path = path.Replace(initialProjectPath, string.Empty); } if (path.LastIndexOf(".") != -1) { path = path.Remove(path.LastIndexOf(".")); } if (path.StartsWith(".")) { path = path.Remove(0, 1); } return(string.IsNullOrEmpty(path) ? "GlobalVariables" : "GlobalVariables." + path); }
public void SetUp() { parser = new GlobalVariableParser(); var xml = @"<?xml version=""1.0"" encoding=""UTF-8""?> <repository xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://www.tibco.com/xmlns/repo/types/2002""> <globalVariables> <globalVariable> <name>Name test 1</name> <value>value test 1</value> <type>String</type> <deploymentSettable>true</deploymentSettable> <serviceSettable>false</serviceSettable> <modTime>13304412311412</modTime> </globalVariable> <globalVariable> <name>Name test 2</name> <value>value test 2</value> <type>String</type> <deploymentSettable>true</deploymentSettable> <serviceSettable>false</serviceSettable> <modTime>13304412311411</modTime> </globalVariable> </globalVariables> </repository>"; doc = XElement.Parse(xml); ConfigurationApp.SaveProperty(MainClass.ProjectDirectory, "c:/myProject"); }
public MainViewModel(Func <string> openFileFunc) { _configurationApp = new ConfigurationApp(); _openFileFunc = openFileFunc; FileOpenCommand = new DelegateCommand(FileOpen); SaveCommand = new DelegateCommand(SaveAsync); }
public static string ConvertXsdImportToNameSpace(string schemaLocation) { var initialProjectPath = ConfigurationApp.GetProperty(MainClass.ProjectDirectory); if (initialProjectPath != null && schemaLocation.StartsWith(initialProjectPath)) { schemaLocation = schemaLocation.Replace(initialProjectPath, string.Empty); } if (schemaLocation.Contains("/")) { string filePath = schemaLocation.Substring(0, schemaLocation.LastIndexOf("/")); filePath = filePath.Remove(0, 1); filePath = filePath.Remove(0, filePath.IndexOf("/") + 1); return(filePath.Replace("/", ".")); } if (schemaLocation.Contains("\\")) { string filePath = schemaLocation.Substring(0, schemaLocation.LastIndexOf("\\")); filePath = filePath.Remove(0, 1); filePath = filePath.Remove(0, filePath.IndexOf("\\") + 1); return(filePath.Replace("\\", ".")); } return(schemaLocation); }
public override CodeNamespaceCollection GenerateClassesToGenerate(Activity activity, Dictionary <string, string> variables) { JavaActivity javaActivity = (JavaActivity)activity; var javaNamespace = new CodeNamespace(javaActivity.PackageName); // Generate the Service javaNamespace.Imports.AddRange(this.GenerateImports()); var javaClass = this.GenerateClass(javaActivity); javaClass.Members.Add(this.GenerateInvokeMethod()); javaNamespace.Types.Add(javaClass); var codeNameSpaces = new CodeNamespaceCollection { javaNamespace }; // Generate the corresponding interface if (ConfigurationApp.GetProperty("IsJavaInterfaceAlreadyGenerated") != "true") { //TODO : Refactor because it's a bit dirty var javaServiceInterfaceNameSpace = InterfaceExtractorFromClass.Extract(javaClass, TargetAppNameSpaceService.javaToolsNameSpace()); javaServiceInterfaceNameSpace.Types[0].Name = IJavaActivityService; codeNameSpaces.Add(javaServiceInterfaceNameSpace); ConfigurationApp.SaveProperty("IsJavaInterfaceAlreadyGenerated", "true"); } return(codeNameSpaces); }
// GET: ConfigurationApps public ActionResult Index() { ConfigurationApp configapp = new ConfigurationApp(); configapp.configuration = db.Configurations.FirstOrDefault(); configapp.reports = db.Reports.ToList(); return(View(configapp)); }
private TibcoBWProcess GetCalledProcess(Activity activity) { var processName = ((CallProcessActivity)activity).ProcessName; var projectDirectory = ConfigurationApp.GetProperty(MainClass.ProjectDirectory); var tibcoProcessToCall = this.parser.Parse(projectDirectory + processName); return(tibcoProcessToCall); }
public void Should_return_2_Classes_To_Generate_if_they_are_not_already_generated() { ConfigurationApp.SaveProperty(RdvPublishActivityBuilder.IsPublisherInterfaceAlreadyGenerated, "false"); ConfigurationApp.SaveProperty(RdvPublishActivityBuilder.IsTibcoPublisherImplemAlreadyGenerated, "false"); var namespaces = this.activityBuilder.GenerateClassesToGenerate(activity, null); Assert.AreEqual(2, namespaces.Count); }
public void Should_return_1_Classe_To_Generate_if_they_are_not_already_generated() { ConfigurationApp.SaveProperty("IsSubscriberInterfaceAlreadyGenerated", "true"); ConfigurationApp.SaveProperty("IsTibcoSubscriberImplemAlreadyGenerated", "false"); var namespaces = this.activityBuilder.GenerateClassesToGenerate(activity, null); Assert.AreEqual(1, namespaces.Count); }
private void CretateOrUpdate(string theme, string accentColor, string filePath) { var configuration = new ConfigurationApp() { Theme = theme, AccentColor = accentColor }; configuration.WriteJson(filePath); }
public CodeNamespaceCollection GenerateClassesToGenerate(Activity activity, Dictionary <string, string> variables) { var namespaces = new CodeNamespaceCollection(); if (ConfigurationApp.GetProperty("IsSubscriberInterfaceAlreadyGenerated") != "true") { namespaces.AddRange(this.subscriberBuilder.GenerateClasses()); ConfigurationApp.SaveProperty("IsSubscriberInterfaceAlreadyGenerated", "true"); } return(namespaces); }
public override CodeNamespaceCollection GenerateClassesToGenerate(Activity activity, Dictionary <string, string> variables) { var result = new CodeNamespaceCollection(); if (ConfigurationApp.GetProperty("IsEngineCommandServiceAlreadyGenerated") != "true") { result.AddRange(this.engineCommandServiceHelperBuilder.Build()); ConfigurationApp.SaveProperty("IsEngineCommandServiceAlreadyGenerated", "true"); } return(result); }
public void Should_Convert_Windows_pathname_in_Code_namespace_to_import() { // Arrange var expected = "DAI.PNO.XSD"; ConfigurationApp.SaveProperty(MainClass.ProjectDirectory, "c:\\test"); // Act var import = TargetAppNameSpaceService.ConvertXsdImportToNameSpace("c:\\test\\XmlSchemas\\DAI\\PNO\\XSD\\RM3D.xsd"); // Assert Assert.AreEqual(expected, import); }
public void Should_Generate_Classes_method_When_XsdReference_is_not_present() { ConfigurationApp.SaveProperty("IsXmlParserHelperAlreadyGenerated", "false"); this.activity.XsdReference = null; var xsdElement = "<element xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n<xsd:element name=\"EquityRecord\" ><xsd:complexType><xsd:sequence><xsd:element name=\"adminID\" type=\"xsd:string\" /></xsd:sequence></xsd:complexType></xsd:element>\n</element>"; XElement doc = XElement.Parse(xsdElement); this.activity.ObjectXNodes = doc.Nodes(); var generatedClasses = xmlParseActivityBuilder.GenerateClassesToGenerate(this.activity, null); Assert.AreEqual(3, generatedClasses.Count); Assert.AreEqual("EquityRecord", generatedClasses[2].Types[0].Name); }
private void CreateSolutionDirectory() { if (Directory.Exists(SolutionDestinationPath) && ConfigurationApp.GetProperty("IsGeneratedSolutionDirectoryPurged") != "true") { Directory.Delete(SolutionDestinationPath, true); ConfigurationApp.SaveProperty("IsGeneratedSolutionDirectoryPurged", "true"); } Directory.CreateDirectory(SolutionDestinationPath); Directory.CreateDirectory(ProjectDestinationPath); Directory.CreateDirectory(ProjectDestinationPath + "/Properties"); Directory.CreateDirectory(ProjectDestinationPath + "/" + ConvertNamespaceToPath(TargetAppNameSpaceService.xmlToolsNameSpace())); }
public override CodeNamespaceCollection GenerateClassesToGenerate(Activity activity, Dictionary <string, string> variables) { var namespaces = new CodeNamespaceCollection(); if (ConfigurationApp.GetProperty(IsPublisherInterfaceAlreadyGenerated) != "true") { namespaces.Add(this.GeneratePublisherInterface()); ConfigurationApp.SaveProperty(IsPublisherInterfaceAlreadyGenerated, "true"); } if (ConfigurationApp.GetProperty(IsTibcoPublisherImplemAlreadyGenerated) != "true") { namespaces.Add(this.GenerateTibcoPublisherImplementation()); ConfigurationApp.SaveProperty(IsTibcoPublisherImplemAlreadyGenerated, "true"); } ModuleBuilder.AddServiceToRegister(InterfaceSubscriberName, ImplementationName); return(namespaces); }
public override CodeNamespaceCollection GenerateClassesToGenerate(Activity activity, Dictionary <string, string> variables) { var result = new CodeNamespaceCollection(); if (ConfigurationApp.GetProperty("IsXmlParserHelperAlreadyGenerated") != "true") { result.AddRange(this.xmlParserHelperBuilder.Build()); ConfigurationApp.SaveProperty("IsXmlParserHelperAlreadyGenerated", "true"); } try { if (activity.ObjectXNodes != null) { result.Add(this.xsdBuilder.Build(activity.ObjectXNodes, this.TargetNamespace(activity))); } } catch (Exception e) { Log.Error("Unable to generate class from XSD file inside XMLParseActivity :" + activity.Name, e); } return(result); }
public override CodeNamespaceCollection GenerateClassesToGenerate(Activity activity, Dictionary <string, string> variables) { var jdbcQueryActivity = (JdbcQueryActivity)activity; var result = new CodeNamespaceCollection(); if (this.HasThisSqlRequestAlreadyGenerateAService(jdbcQueryActivity.QueryStatement)) { this.ServiceToInvoke = this.GetExistingJdbcServiceName(jdbcQueryActivity.QueryStatement); jdbcQueryActivity.ClassName = this.ServiceToInvoke.Replace("Service", string.Empty); } else { jdbcQueryActivity.ClassName = this.GenerateClassName(jdbcQueryActivity); this.ServiceToInvoke = jdbcQueryActivity.ClassName + "Service"; SqlRequestToActivityMapper.SaveSqlRequest(jdbcQueryActivity.QueryStatement, this.ServiceToInvoke); if (jdbcQueryActivity.QueryOutputStatementParameters != null && jdbcQueryActivity.QueryOutputStatementParameters.Count != 0) { result.Add(this.resultSetBuilder.Build(jdbcQueryActivity)); } var dataAccessNameSpace = this.dataAccessBuilder.Build(jdbcQueryActivity); var dataAccessInterfaceNameSpace = InterfaceExtractorFromClass.Extract(dataAccessNameSpace.Types[0], TargetAppNameSpaceService.dataAccessNamespace()); if (jdbcQueryActivity.QueryOutputStatementParameters != null && jdbcQueryActivity.QueryOutputStatementParameters.Count != 0) { dataAccessInterfaceNameSpace.Imports.Add(new CodeNamespaceImport(TargetAppNameSpaceService.domainContractNamespaceName())); } dataAccessNameSpace.Types[0].BaseTypes.Add(new CodeTypeReference(dataAccessInterfaceNameSpace.Types[0].Name)); var serviceNameSpace = this.dataAccessServiceBuilder.Build(jdbcQueryActivity); var serviceInterfaceNameSpace = InterfaceExtractorFromClass.Extract(serviceNameSpace.Types[0], TargetAppNameSpaceService.domainContractNamespaceName()); serviceNameSpace.Types[0].BaseTypes.Add(new CodeTypeReference(serviceInterfaceNameSpace.Types[0].Name)); result.Add(dataAccessNameSpace); result.Add(dataAccessInterfaceNameSpace); result.Add(serviceNameSpace); result.Add(serviceInterfaceNameSpace); if (ConfigurationApp.GetProperty("HasCommonDataAccessAlreadyGenerated") != "true") { var dataCommonNamespace = this.dataAccessCommonBuilder.Build(); result.Add(dataCommonNamespace); ConfigurationApp.SaveProperty("HasCommonDataAccessAlreadyGenerated", "true"); } //TODO : Find a more suitable way to retrieve the CustomAttribute To Build string dataCustomAttributeName = this.GetDataCustomAttributeName(dataAccessNameSpace); if (ConfigurationApp.GetProperty(dataCustomAttributeName) != "true") { var dataBaseAttributeNamespace = new DatabaseAttributeBuilder().Build(dataCustomAttributeName); result.Add(dataBaseAttributeNamespace); ConfigurationApp.SaveProperty(dataCustomAttributeName, "true"); } ModuleBuilder.AddServiceToRegister(dataAccessInterfaceNameSpace.Types[0].Name, dataAccessNameSpace.Types[0].Name); ModuleBuilder.AddServiceToRegister(serviceInterfaceNameSpace.Types[0].Name, this.ServiceToInvoke); } return(result); }
public static void Main(string[] args) { BasicConfigurator.Configure(); IDirectoryProcessorService tibcoFileReaderService; IFileProcessorService tibcoFileProcessorService; IFileProcessorService xsdFileProcessorService; IFileProcessorService globalVariableProcessor; IFileProcessorService adapterFileProcessorService; ISourceCodeGeneratorService sourceCodeGeneratorService; PostProcessor postProcessor; IFileFilter fileFilter; if (args.Length > 1) { var sourceDirectory = args[0]; var mode = args[1]; string initFilePath = string.Empty; Log.Info("You've inputed DIRECTORY: " + sourceDirectory); Log.Info("You've inputed MODE: " + mode); if (args.Length > 2) { initFilePath = args[2]; Log.Info("You've inputed FILTERING FILE: " + initFilePath); } // TODO VC : improve arg management in input if (args.Length > 3) { var targetApplicationName = args[3]; TargetAppNameSpaceService.MyAppName = targetApplicationName; Log.Info("You've inputed an application namespace: " + targetApplicationName); } fileFilter = new FileFilter(initFilePath); ConfigurationApp.SaveProperty(ProjectDirectory, sourceDirectory); if (mode == "S_Csharp") { Log.Info("You've mode: " + mode); sourceCodeGeneratorService = new CsharpSimulationSourceCodeGeneratorService(); tibcoFileProcessorService = new TibcoFileProcessorService(sourceCodeGeneratorService); xsdFileProcessorService = new XsdFileProcessorService(sourceCodeGeneratorService); globalVariableProcessor = new GlobalVariableProcessor(sourceCodeGeneratorService); adapterFileProcessorService = new AdapterFileProcessorService(sourceCodeGeneratorService); tibcoFileReaderService = new TibcoBWDirectoryProcessorService(tibcoFileProcessorService, xsdFileProcessorService, globalVariableProcessor, adapterFileProcessorService, fileFilter); postProcessor = new PostProcessor(sourceCodeGeneratorService); tibcoFileReaderService.Process(sourceDirectory); postProcessor.Process(); } else if (mode == "G_Csharp") { sourceCodeGeneratorService = new CsharpSourceCodeGeneratorService(); tibcoFileProcessorService = new TibcoFileProcessorService(sourceCodeGeneratorService); xsdFileProcessorService = new XsdFileProcessorService(sourceCodeGeneratorService); globalVariableProcessor = new GlobalVariableProcessor(sourceCodeGeneratorService); adapterFileProcessorService = new AdapterFileProcessorService(sourceCodeGeneratorService); tibcoFileReaderService = new TibcoBWDirectoryProcessorService(tibcoFileProcessorService, xsdFileProcessorService, globalVariableProcessor, adapterFileProcessorService, fileFilter); postProcessor = new PostProcessor(sourceCodeGeneratorService); tibcoFileReaderService.Process(sourceDirectory); postProcessor.Process(); } else if (mode == "A") { var tibcoDependencyAnalyserProcessorService = new TibcoDependencyAnalyserProcessorService(new AnalyserFileProcessorService()); ConfigurationApp.SaveProperty(ProjectDirectory, sourceDirectory); var processToAnalyseFileName = args[2]; tibcoDependencyAnalyserProcessorService.Process(processToAnalyseFileName); } else { Log.Error("Program is going to exit - sorry only MODE S_Csharp, G_Csharp and A are managed for the moment"); } } else { DisplayErrorMessage(); return; } Console.ReadLine(); }