public override List <CodeNamespaceImport> GenerateImports(Activity activity)
 {
     return(new List <CodeNamespaceImport>
     {
         new CodeNamespaceImport(TargetAppNameSpaceService.domainContractNamespaceName())
     });
 }
Exemple #2
0
        public override List <CodeNamespaceImport> GenerateImports(Activity activity)
        {
            var jdbcQueryActivity = (JdbcQueryActivity)activity;

            var imports = new List <CodeNamespaceImport>
            {
                new CodeNamespaceImport(TargetAppNameSpaceService.domainContractNamespaceName())
            };

            if (jdbcQueryActivity.QueryOutputStatementParameters != null)
            {
                imports.Add(new CodeNamespaceImport("System.Collections.Generic"));
            }

            return(imports);
        }
        public CodeNamespaceImport[] GenerateServiceImport(JdbcQueryActivity jdbcQueryActivity)
        {
            var imports = new List <CodeNamespaceImport>
            {
                new CodeNamespaceImport("System"),
                new CodeNamespaceImport(TargetAppNameSpaceService.domainContractNamespaceName()),
                new CodeNamespaceImport(TargetAppNameSpaceService.dataAccessNamespace())
            };

            if (jdbcQueryActivity.QueryOutputStatementParameters != null)
            {
                imports.Add(new CodeNamespaceImport("System.Collections.Generic"));
            }

            return(imports.ToArray());
        }
        private CodeNamespaceImport[] GenerateImports()
        {
            var imports = new List <CodeNamespaceImport>
            {
                new CodeNamespaceImport("System"),
                new CodeNamespaceImport(TargetAppNameSpaceService.domainContractNamespaceName()),
                new CodeNamespaceImport(TargetAppNameSpaceService.dataAccessNamespace()),
                new CodeNamespaceImport(TargetAppNameSpaceService.domainServiceNamespaceName()),
                new CodeNamespaceImport(TargetAppNameSpaceService.EngineCommandNamespace()),
                new CodeNamespaceImport(TargetAppNameSpaceService.dataAccessNamespace()),
                new CodeNamespaceImport(TargetAppNameSpaceService.EventSourcingNameSpace()),
                new CodeNamespaceImport(TargetAppNameSpaceService.loggerNameSpace()),
                new CodeNamespaceImport(TargetAppNameSpaceService.xmlToolsNameSpace())
            };

            return(imports.ToArray());
        }
Exemple #5
0
        public void Should_generate_class()
        {
            var resultSetNameSpace = this.resultSetBuilder.Build(this.jdbcQueryActivity);
            var generatedCode      = TestCodeGeneratorUtils.GenerateCode(resultSetNameSpace);

            Assert.AreEqual(@"namespace " + TargetAppNameSpaceService.domainContractNamespaceName() + @"
{
    using System;
    
    
    public class Currency
    {
        
        public System.String FirstOutput { get; set; }
        public System.String SecondOutput { get; set; }
    }
}
", generatedCode);
        }
Exemple #6
0
        public CodeNamespace Build(JdbcQueryActivity jdbcQueryActivity)
        {
            var resultSetNameSpace = new CodeNamespace(TargetAppNameSpaceService.domainContractNamespaceName());

            resultSetNameSpace.Imports.AddRange(this.GenerateImport(jdbcQueryActivity));

            var resultSetClass = new CodeTypeDeclaration
            {
                IsClass        = true,
                TypeAttributes = TypeAttributes.Public,
                Name           = VariableHelper.ToClassName(jdbcQueryActivity.ClassName)
            };

            resultSetClass.Members.AddRange(this.GenererateProperties(jdbcQueryActivity));

            resultSetNameSpace.Types.Add(resultSetClass);

            return(resultSetNameSpace);
        }
Exemple #7
0
        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);
        }
 private string TargetNamespace(Activity activity)
 {
     return(TargetAppNameSpaceService.domainContractNamespaceName() + "." + VariableHelper.ToClassName(activity.Name));
 }