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());
        }
Exemplo n.º 2
0
        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());
        }
Exemplo n.º 3
0
        public CodeNamespace Build(JdbcQueryActivity jdbcQueryActivity)
        {
            var dataAccessNameSpace = new CodeNamespace(TargetAppNameSpaceService.dataAccessNamespace());

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

            var dataAccessToGenerate = new CodeTypeDeclaration();

            dataAccessToGenerate.IsClass        = true;
            dataAccessToGenerate.TypeAttributes = TypeAttributes.Public;

            dataAccessToGenerate.Name = VariableHelper.ToClassName(jdbcQueryActivity.ClassName) + "DataAccess";

            dataAccessToGenerate.Members.AddRange(this.GenererateFields(jdbcQueryActivity));
            dataAccessToGenerate.Members.AddRange(this.GenererateContructors(jdbcQueryActivity, dataAccessToGenerate));
            dataAccessToGenerate.Members.AddRange(this.GenererateMethods(jdbcQueryActivity));

            dataAccessNameSpace.Types.Add(dataAccessToGenerate);

            return(dataAccessNameSpace);
        }
Exemplo n.º 4
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);
        }