Exemplo n.º 1
0
        public static void ProcessPackages(AstRootNode astRootNode)
        {
            foreach (var package in astRootNode.Packages)
            {
                _processPackage(package);
            }

            _processMetadataTasks(astRootNode.SymbolTable);
        }
Exemplo n.º 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);
         }
     }
 }
Exemplo n.º 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));
                }
            }
        }
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 6
0
 public AstIR(AstIR astIR) : base(astIR)
 {
     this._astRootNode = astIR._astRootNode;
 }
Exemplo n.º 7
0
Arquivo: AstIR.cs Projeto: japj/vulcan
 public AstIR(AstIR astIR) : base(astIR)
 {
     this._astRootNode = astIR._astRootNode;
 }