示例#1
0
        public static void ProcessPackages(AstRootNode astRootNode)
        {
            foreach (var package in astRootNode.Packages)
            {
                _processPackage(package);
            }

            _processMetadataTasks(astRootNode.SymbolTable);
        }
示例#2
0
 public static void ProcessSchemas(AstRootNode astRootNode)
 {
     var snapshotSymbolTable = new List<IReferenceableItem>(astRootNode.SymbolTable);
     foreach (var astNamedNode in snapshotSymbolTable)
     {
         var schemaNode = astNamedNode as AstSchemaNode;
         if (schemaNode != null && astNamedNode.FirstThisOrParent<ITemplate>() == null)
         {
             ProcessSchema(astRootNode, schemaNode);
         }
     }
 }
示例#3
0
        private static void ProcessTables(AstRootNode astRootNode)
        {
            var tables = new List<AstTableBaseNode>(astRootNode.Tables);
            foreach (var dimension in astRootNode.Dimensions)
            {
                tables.Add(dimension);
            }

            foreach (var fact in astRootNode.Facts)
            {
                tables.Add(fact);
            }

            foreach (AstTableNode table in tables)
            {
                if (table.LateArriving)
                {
                    LateArrivingLowerer.ProcessLateArrivingTable(table);
                }

                if (table.HasScdColumns)
                {
                    SlowlyChangingDimensionsLowerer.ProcessTableScdColumns(table);
                }

                foreach (var staticSourcePackage in StaticSourcesLowerer.ProcessTableStaticSource(table))
                {
                    astRootNode.Packages.Add(staticSourcePackage);
                }

                if (!(table is AstTableCloneNode) && table.EmitVersionNumber)
                {
                    var versionNumber = new AstTableColumnNode(table) 
                    { 
                        Name = "VersionNumber",
                        ColumnType = ColumnType.Binary,
                        Length = 8,
                        CustomType="rowversion",
                        IsAssignable=false,
                        IsNullable = false,
                        IsAutoGenerated = true 
                    };
                    table.Columns.Add(versionNumber);
                }

                if (table.Emit)
                {
                    astRootNode.Packages.Add(TableLowerer.ProcessTable(table));
                }
            }
        }
示例#4
0
        public static void ProcessPrincipals(AstRootNode astRootNode)
        {
            if (astRootNode.Principals.Count > 0)
            {
                var package = new AstPackageNode(astRootNode) { Name = "PrincipalsInitializer", Emit = true, PackageType = "Principal" };
                astRootNode.Packages.Add(package);

                foreach (AstPrincipalNode principal in astRootNode.Principals)
                {
                    TemplatePlatformEmitter principalTemplate;
                    switch (principal.PrincipalType)
                    {
                        case PrincipalType.ApplicationRole:
                            principalTemplate = new TemplatePlatformEmitter("CreatePrincipalApplicationRole", principal.Name);
                            break;
                        case PrincipalType.DBRole:
                            principalTemplate = new TemplatePlatformEmitter("CreatePrincipalDatabaseRole", principal.Name);
                            break;
                        case PrincipalType.SqlUser:
                            principalTemplate = new TemplatePlatformEmitter("CreatePrincipalSqlUser", principal.Name);
                            break;
                        case PrincipalType.WindowsGroup:
                            principalTemplate = new TemplatePlatformEmitter("CreatePrincipalWindowsUser", principal.Name);
                            break;
                        case PrincipalType.WindowsUser:
                            principalTemplate = new TemplatePlatformEmitter("CreatePrincipalWindowsUser", principal.Name);
                            break;
                        default:
                            MessageEngine.Trace(principal, Severity.Error, "V0139", "Unknown Principal Type {0} in principal {1}", principal.PrincipalType.ToString(), principal.Name);
                            return;
                    }

                    var executeSqlTask = new AstExecuteSqlTaskNode(package)
                    {
                        Name = Utility.NameCleanerAndUniqifier(String.Format(CultureInfo.InvariantCulture, "PrincipalConfig_{0}", principal.Name)),
                        Connection = principal.Connection
                    };
                    executeSqlTask.Query = new AstExecuteSqlQueryNode(executeSqlTask)
                                               {
                                                   Body = principalTemplate.Emit(),
                                                   QueryType = QueryType.Standard
                                               };
                    package.Tasks.Add(executeSqlTask);
                }
            }
        }
示例#5
0
        public static void ProcessSchema(AstRootNode astRootNode, AstSchemaNode schemaNode)
        {
            const string PackageTypeName = "Schema";

            var packageNode = new AstPackageNode(schemaNode.ParentItem);
            packageNode.Name = schemaNode.Name;
            packageNode.PackageType = PackageTypeName;

            var executeSqlNode = new AstExecuteSqlTaskNode(packageNode) { Name = schemaNode.Name, Connection = schemaNode.Connection, ResultSet = ExecuteSqlResultSet.None };
            executeSqlNode.Query = new AstExecuteSqlQueryNode(executeSqlNode) { QueryType = QueryType.Standard, Body = new TemplatePlatformEmitter("CreateSchema", schemaNode.Name).Emit() };

            packageNode.Tasks.Add(executeSqlNode);

            bool hasPermissions = false;
            var permissionBuilder = new StringBuilder();
            foreach (var permission in schemaNode.Permissions)
            {
                hasPermissions = true;
                permissionBuilder.AppendLine(PermissionsLowerer.ProcessPermission(schemaNode, permission));
            }

            if (hasPermissions)
            {
                var permissionsExecuteSqlTask = new AstExecuteSqlTaskNode(packageNode)
                {
                    Name = "__SetPermissions",
                    Connection = schemaNode.Connection,
                };
                permissionsExecuteSqlTask.Query = new AstExecuteSqlQueryNode(permissionsExecuteSqlTask)
                {
                    Body = permissionBuilder.ToString(),
                    QueryType = QueryType.Standard
                };
                packageNode.Tasks.Add(permissionsExecuteSqlTask);
            }

            if (schemaNode.CustomExtensions != null)
            {
                packageNode.Tasks.Add(schemaNode.CustomExtensions);
            }

            astRootNode.Packages.Add(packageNode);
        }
示例#6
0
 public AstIR(AstIR astIR) : base(astIR)
 {
     this._astRootNode = astIR._astRootNode;
 }
示例#7
0
文件: AstIR.cs 项目: japj/vulcan
 public AstIR(AstIR astIR) : base(astIR)
 {
     this._astRootNode = astIR._astRootNode;
 }